#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
const int N = 30;
int arr[N],cal[N];
int n, k, cnt=0;
bool prime(int num)
{
	if (num < 2)return false;
	for (int i = 2; i <= num / i; i++)
	{
		if (num % i == 0)return false;
	}
	return true;
}
void dfs(int x, int start)
{
	if (x + n < k + start)return;
	if (x > k)
	{
		int sum = 0;
		for (int i = 1; i <= k; i++)
		{
			sum += cal[i];
		}
		if (prime(sum))cnt++;
		return;
	}
	for (int i = start; i <= n; i++)
	{
		cal[x] = arr[i];
		dfs(x + 1, i + 1);
		cal[x] = 0;
	}
}
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &arr[i]);
	}
	dfs(1, 1);
	printf("%d", cnt);
	return 0;
}